package net.huashitong.user.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.user.entity.MessageReminding;
import net.huashitong.user.filter.MessageRemindingFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 消息
 * Created by hyp1202 on 2018/7/4.
 */
@Repository
public class MessageRemindingDao extends StringDao<MessageReminding>{
    /**
     * 查询消息
     * @param filter
     * @return
     */
    public List<MessageReminding> getMessageInfo(MessageRemindingFilter filter){
        GenericQuery query = createQuery("obj");
        if (filter.getAddresser()!=null&&!"".equals(filter.getAddresser()))
            query.append(" and addresser =:addresser").setParam("addresser",filter.getAddresser());
        if (filter.getRecipients()!=null&&!"".equals(filter.getRecipients()))
            query.append(" and recipients like:recipients").setParam("recipients",filter.getRecipients());
        if (filter.getState()!=null&&!"".equals(filter.getState()))
            query.append(" and state =:state").setParam("state",filter.getState());
        if (filter.getTitle()!=null&&!"".equals(filter.getTitle()))
            query.append(" and title =:title").setParam("title",filter.getTitle());
        return query.listResult(filter);
    }
}
